<?php
/**
 * Created by PhpStorm.
 * User: yangyou
 * Date: 2018/12/4 0004
 * Time: 14:14
 */

namespace app\index\model;

use tools\PinYin;


class Config extends Base
{
    public function drawingList(){
        $select = $this->where("config_type",'in',['DrawingType','DrawingProgramme','DrawingFrameStructure','DrawingStyle','DrawingProperty'])->select();
        foreach ($select as $val){
            $result[$val["config_id"]] = $val["config_name"];
        }
        return $result;
    }

    /**
     * Author:yang you
     * Time:2018-12-2 10:27:51
     * Describe:设计师类型
     * @return int|string
     */
    public function designerType(){
        $select = $this->where("config_type",'in',['DesignerLevel'])->select();
        foreach ($select as $key=>$val){
            $result[$key]["config_name"] = $val["config_name"];
            $result[$key]["config_id"] = $val["config_id"];
        }
        return $result;
    }

    /**
     * Author:yang you
     * Time:2018-12-2 10:27:51
     * Describe:图纸风格
     * @return int|string
     */
    public function drawingStyle(){
        $select = $this->where("config_type",'in',['DrawingStyle'])->select();
        foreach ($select as $key=>$val){
            $result[$key]["config_name"] = $val["config_name"];
            $result[$key]["config_id"] = $val["config_id"];
        }
        return $result;
    }

    /**
     * Author:yang you
     * Time:2018-12-5 10:27:51
     * Describe:结构形式
     * @return int|string
     */
    public function configType($config_type){
        $select = $this->where("config_type",$config_type)->select();
        foreach ($select as $key=>$val){
            $result[$key]["config_name"] = $val["config_name"];
            $result[$key]["config_id"] = $val["config_id"];
        }
        return $result;
    }

    /**
     * Author:yang you
     * Time:2018-12-05 09:35:27
     * Describe:获取配置类型列表-带拼音
     * @param $config_type
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getConfigTypeListPY($config_type){
        $select = $this->field("config_id,config_name,config_url")->where("config_type",$config_type)->select();
        $PinYin = new PinYin();
        foreach ($select as $key=>$val){
            $result[$key]['py'] = $val["config_url"];
            $result[$key]["config_name"] = $val["config_name"];
            $result[$key]["config_id"] = $val["config_id"];
        }
        return $result;
    }


}